﻿using BLL.Interface;
using Common.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model.DTO.Public.GetList;
using Model.DTO.Public.OperateId;
using Model.DTO.User;

namespace TianXiaHuiForumManagementSystem.Controllers.Admin
{
    [Route("Admin/[controller]")]
    [ApiController]
    public class UserTypeController : ControllerBase
    {
        private readonly IUserTypeBLL _userTypeBLL;
        public UserTypeController(IUserTypeBLL userTypeBLL)
        {
            _userTypeBLL = userTypeBLL;
        }
        /// <summary>
        /// 添加用户类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost,Route("AddUserType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> AddUserType(AddUserTypeDTO param)
        {
            var result = await _userTypeBLL.AddUserType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 删除用户类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost,Route("DeleteUserType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> DeleteUserType(OperateIdDTO_INT param)
        {
            var result = await _userTypeBLL.DeleteUserType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 更新用户类型
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost,Route("EditUserType")]
        [Authorize(Roles = "Admin")]
        public async Task<string> EditUserType(EditUserTypeDTO param)
        {
            var result = await _userTypeBLL.EditUserType(param);
            return result.ToJsonFormat();
        }
        /// <summary>
        /// 获取用户类型列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="roleName"></param>
        /// <returns></returns>
        [HttpPost, Route("GetUserTypeList")]
        public async Task<string> GetUserTypeList(GetListDTO param)
        {
            var result = await _userTypeBLL.GetUserTypeList(param);
            return result.ToJsonFormat();
        }
    }
}
